﻿using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UMLSynthesizer.LangAnalyzer.Elements;
using UMLSynthesizer.LangAnalyzer.Expressions;
using UMLSynthesizer.LangAnalyzer.Statements;

namespace UMLSynthesizer.CSharpAnalyzer.Expressions
{
    abstract class CSharpExpressionBase : IExpressionBase
    {
        #region Fields

        protected ExpressionSyntax expressionNode;

        #endregion

        #region Constructor

        public CSharpExpressionBase(ExpressionSyntax expressionNode,
            IExpressionBase parentExpression,
            IStatementBase parentStatement,
            ExpressionKinds kind)
        {
            if (parentExpression == null && parentStatement == null)
                throw new ArgumentNullException("parentExpression && parentStatement");

            this.expressionNode = expressionNode;
            this.ParentExpression = parentExpression;
            if (parentExpression != null)
                this.ParentStatement = parentExpression.ParentStatement;
            else
                this.ParentStatement = parentStatement;
            this.ParentElement = this.ParentStatement.ParentElement;
            this.ProjectOwner = this.ParentElement.ProjectOwner;

            this.Kind = kind;
        }

        #endregion

        #region Properties

        public IExpressionBase ParentExpression { get; protected set; }
        public IStatementBase ParentStatement { get; protected set; }
        public IElementBase ParentElement { get; protected set; }
        public IProjectElement ProjectOwner { get; protected set; }

        public ExpressionKinds Kind { get; protected set; }

        #endregion
    }
}
